package com.jokins.admin.vue.gitlog.service.impl;

import com.jokins.admin.vue.gitlog.actioncontext.GetGiteeLogsListDoc;
import com.jokins.admin.vue.gitlog.actioncontext.SaveHandleGithubWebhookDoc;
import com.jokins.admin.vue.gitlog.param.GitPushLogsParam;
import com.jokins.admin.vue.gitlog.param.SaveGitPushParam;
import com.jokins.admin.vue.gitlog.service.GitWebhookService;
import com.jokins.admin.vue.gitlog.vo.GitPushLogsVo;
import com.jokins.common.actions.action.ActionContext;
import com.jokins.common.actions.util.ActionDispatcher;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class GitWebhookServiceImpl implements GitWebhookService {



    @Override
    public ResponseEntity<?> SaveHandleGithubWebhook(SaveGitPushParam param) {
        SaveHandleGithubWebhookDoc doc = new SaveHandleGithubWebhookDoc(param);
        ActionDispatcher.execute(doc);
        return (ResponseEntity<?>) doc.getResultValue(ActionContext.RESULT_DOC_KEY);
    }

    @Override
    public List<GitPushLogsVo> getGiteeLogsList(GitPushLogsParam param) {
        GetGiteeLogsListDoc doc = new GetGiteeLogsListDoc(param);
        ActionDispatcher.execute(doc);
        return (List<GitPushLogsVo>) doc.getResultValue(ActionContext.RESULT_DOC_KEY);
    }
}
